package com.xinyuan.servlet;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.xinyuan.entity.ResultInfo;
import com.xinyuan.service.GetJson;
import com.xinyuan.service.WorkHourService;
import com.xinyuan.utils.AmecoUtils;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "campUploadServlet",urlPatterns = "/campUpload")
public class CampUpload extends HttpServlet {
    String filePath = "";
    GetJson json = new GetJson();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.addHeader("Access-Control-Allow-Origin","*");
        //获取用户id
        String fileID = req.getParameter("id");
        //String fileID = "1";
        AmecoUtils utils = new AmecoUtils();
        filePath = utils.uploadFile(req,resp,"CAMP",fileID);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       this.doPost(req, resp);
    }
}
